﻿@model CampWeek5__Book_Project_.Models.BookVM
@{
    ViewBag.Title = "BookDetail";
}

<div>
    <h2>@Model.Title</h2><p>
        Genres: @string.Join(", ", Model.Tags)
    </p>
</div>

<div class="container">

    <div class="col-md-3">
        <img src="@Model.BookImg" class="img-responsive img-thumbnail dg-bookDetailImage" />
        <h4>@Model.TimesViewed Viewed</h4>
        @if (User.Identity.IsAuthenticated)
        {
            <a href="/Admin/AdminEditBook/@Model.Id" class="btn btn-warning">Edit</a>  <a href="/Home/AdminDeleteBook/@Model.Id" class="btn btn-danger">Delete</a>
            <a href="/Home/SelectFeaturedBook/@Model.ISBN" class="btn btn-info">Feature</a>
        }
    </div>

    <div class="col-md-9">
        <h3>Author:  <strong><a href="/Details/AuthorDetail/@Model.AuthorId">@Model.AuthorName</a></strong></h3>
        <p>
            Publication Date: @Model.PubDate
        </p>
        <p>@Model.Summary</p>
        @if (User.Identity.IsAuthenticated)
        {
            <a href="/Home/CreateRating/@Model.Id" class="btn btn-info">Rate this book!</a>
        }
        <h3>Ratings:</h3>
        <p>
            @foreach (var r in Model.Ratings)
            {
                if (r.Comment != null)
                {
                    <div class="panel">
                        <div class="panel-heading">
                            @r.Username gives @r.BookRating stars
                        </div>
                        <div class="panel-body">
                            @r.Comment
                        </div>
                    </div>
                }
            }
        </p>
    </div>
</div>